package m3d31;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

//Properties集合继承了hashtable  唯一和IO流相结合的集合
public class fProperties {
    public static void main(String[] args) throws IOException {
        Properties prop = new Properties();
        //添加数据
        prop.setProperty("1","aaa");
        prop.setProperty("2","bbb");
        prop.setProperty("3","ccc");

        //把集合的键取出放到集合
        Set<String> set = prop.stringPropertyNames();

        //遍历Set，取出集合的键
        for (String key:set
             ) {
            String value = prop.getProperty(key);
            System.out.println(key+value);
        }

        FileWriter fw = new FileWriter("day02\\src\\m3d31\\b.txt");

        //把集合数据写入硬盘          注释
        prop.store(fw,"save.date");

        fw.close();

        //匿名对象流使用完自己就关了
        prop.store(new FileOutputStream("day02\\src\\m3d31\\b.txt",true),"");
    }
}
